package com.visikard.response;

import java.util.ArrayList;
import java.util.List;

import org.json.JSONException;
import org.json.JSONObject;

import android.util.Log;

import com.visikard.application.Constant;
import com.visikard.item.ItemGiftKardRedeem;

public class GetGiftKardResponse extends BaseResponse {
	public static final int ERROR_NOT_FOUND = BaseResponse.USER_DEFINED_ERROR;

	private List<ItemGiftKardRedeem> listGiftKards;

	public List<ItemGiftKardRedeem> getListGiftKards() {
		return listGiftKards;
	}

	public void setListGiftKards(List<ItemGiftKardRedeem> listGiftKards) {
		this.listGiftKards = listGiftKards;
	}

	@Override
	public void extractDataFromServer(String response) throws JSONException {
		super.extractDataFromServer(response);

		if (errorCode == SUCCESS) {
			JSONObject jDataObj = getDataJObject(response);
			ArrayList<ItemGiftKardRedeem> giftKards = new ArrayList<ItemGiftKardRedeem>();
			ItemGiftKardRedeem item = new ItemGiftKardRedeem(jDataObj);
			giftKards.add(item);
			listGiftKards = giftKards;
		}
		else if (response != null && !response.isEmpty()) {
			Log.e(Constant.LOG_TAG, "getGiftKardList: " + "Not Found!!!");
			errorCode = GetGiftKardResponse.ERROR_NOT_FOUND;
			errorMsg = "Not Found";
		}
	}

}
